Skip to content

Revert "fix: resolve BudgetExceededError CLI traceback issues (fixes #1627)"#1642

Merged
MervinPraison merged 1 commit into
mainfrom
revert-1635-claude/issue-1627-20260507-0941
May 9, 2026
Merged

Revert "fix: resolve BudgetExceededError CLI traceback issues (fixes #1627)"#1642
MervinPraison merged 1 commit into
mainfrom
revert-1635-claude/issue-1627-20260507-0941

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

@MervinPraison MervinPraison commented May 9, 2026

Reverts #1635

Summary by CodeRabbit

  • Refactor
    • Removed max_budget convenience parameter from Agent constructor initialization. Budget limits must now be configured exclusively through the ExecutionConfig parameter when creating agents.
    • Streamlined internal execution logic by eliminating budget handling wrapper functions and consolidating direct agent execution calls across all output display modes for improved code maintainability and architectural clarity.

Review Change Stack

Copilot AI review requested due to automatic review settings May 9, 2026 21:43
@qodo-code-review
Copy link
Copy Markdown

β“˜ You've reached your Qodo monthly free-tier limit. Reviews pause until next month β€” upgrade your plan to continue now, or link your paid account if you already have one.

@MervinPraison MervinPraison merged commit 78f0a71 into main May 9, 2026
10 of 11 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 49172e3d-e798-4ea2-bd1b-ba356a252bbc

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between e01f63d and 9a0f695.

πŸ“’ Files selected for processing (2)
  • src/praisonai-agents/praisonaiagents/agent/agent.py
  • src/praisonai/praisonai/cli/main.py

πŸ“ Walkthrough

Walkthrough

This PR consolidates budget handling by removing the max_budget convenience parameter from Agent.__init__ and its supporting wrapper in the CLI. Budget configuration now applies exclusively through the ExecutionConfig path. The _execute_agent_with_budget_handling helper was deleted, and all direct-execution call sites were updated to invoke agent methods directly.

Changes

Budget Handling Consolidation

Layer / File(s) Summary
API Contract
src/praisonai-agents/praisonaiagents/agent/agent.py
Removed max_budget: Optional[float] parameter from Agent.__init__ signature and deleted the corresponding docstring entry.
Implementation Logic
src/praisonai-agents/praisonaiagents/agent/agent.py
Removed the __init__ logic block that merged max_budget into ExecutionConfig(max_budget=...) with precedence/warning behavior.
CLI Wrapper Removal
src/praisonai/praisonai/cli/main.py
Removed the internal _execute_agent_with_budget_handling(...) helper method.
CLI Call Site Updates
src/praisonai/praisonai/cli/main.py
Updated all direct-prompt execution paths (AutoRag, silent/quiet, verbose, debug, jsonl, json, flow, editor, and default modes) and final-agent post-processing to call agent.start(), agent.chat(), and auto_rag.chat() directly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • MervinPraison/PraisonAI#1635: Reverses these exact changes by re-adding the Agent max_budget parameter and _execute_agent_with_budget_handling wrapper; directly related in scope and affected code.
  • MervinPraison/PraisonAI#1436: Modifies agent invocation paths in src/praisonai/praisonai/cli/main.py similarly, affecting direct agent execution control flow.

Poem

A rabbit hops through code so clean,
Removing paths that aren't seen,
One config path now shines so bright,
Budget flows, consolidated right! 🐰✨

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-1635-claude/issue-1627-20260507-0941

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MervinPraison
Copy link
Copy Markdown
Owner Author

@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β€” incorporate their findings.

Review areas:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the 'max_budget' convenience parameter from the Agent constructor and deletes the '_execute_agent_with_budget_handling' helper method in the CLI, replacing it with direct calls to agent methods. The review feedback highlights that removing 'max_budget' is a breaking change and suggests using deprecation instead. Furthermore, the removal of the budget handling logic in the CLI is identified as a regression that will lead to unhandled exceptions and a poor user experience when budget limits are reached.

verification_hooks: Optional[List[Any]] = None, # Deprecated: use autonomy=AutonomyConfig(verification_hooks=[...])
output: Optional[Union[bool, str, Dict[str, Any], 'OutputConfig']] = None,
execution: Optional[Union[bool, str, Dict[str, Any], 'ExecutionConfig']] = None,
max_budget: Optional[float] = None, # Budget limit in USD - convenience alias for ExecutionConfig(max_budget=...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing the "max_budget" parameter from the Agent constructor is a breaking change for users who rely on this convenience alias. If this feature was already released, it is recommended to keep the parameter as deprecated instead of removing it entirely to avoid breaking existing implementations.


with Live(Panel(Spinner("dots", text="Generating..."), border_style="cyan"), refresh_per_second=10, transient=True):
result = self._execute_agent_with_budget_handling(auto_rag, 'chat', prompt)
result = auto_rag.chat(prompt)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By reverting the graceful error handling, this direct call to "auto_rag.chat(prompt)" will now cause the CLI to crash with a full traceback if a BudgetExceededError is raised. This regresses the fix for issue #1627 and negatively impacts the user experience for budget-constrained runs.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR reverts #1635, which had introduced graceful BudgetExceededError handling in the CLI and a max_budget convenience parameter on the Agent constructor. The revert removes both without replacing them with alternative implementations.

  • cli/main.py: Deletes _execute_agent_with_budget_handling and reverts all 16 call sites to direct agent.start()/agent.chat() calls. BudgetExceededError raised in chat_mixin.py is now unhandled at the CLI layer, restoring the raw traceback from [DX] BudgetExceededError surfaces raw traceback in CLIΒ #1627.
  • agent.py: Removes the max_budget keyword argument from Agent.__init__ along with the merge/conflict-warning logic; callers that were using Agent(max_budget=1.00) will now receive a TypeError at runtime.

Confidence Score: 3/5

Merging re-introduces a known CLI regression where budget overruns produce a raw Python traceback instead of a clean error message, and removes a constructor parameter that users may already be relying on.

Both changes are straight reverts with no compensating fixes: BudgetExceededError is once again unhandled in the CLI layer (the exact scenario from #1627), and the max_budget shorthand is silently gone. A user who hits a budget limit now sees a traceback; a user who calls Agent(max_budget=...) gets a TypeError.

src/praisonai/praisonai/cli/main.py needs the most attention β€” the absence of any BudgetExceededError catch is the most user-visible regression.

Important Files Changed

Filename Overview
src/praisonai/praisonai/cli/main.py Removes _execute_agent_with_budget_handling and all 16 call sites, reverting back to direct agent.start()/agent.chat() calls β€” restoring the unhandled BudgetExceededError traceback from issue #1627
src/praisonai-agents/praisonaiagents/agent/agent.py Removes the max_budget convenience constructor parameter and all associated merging/warning logic; users must now use the full execution=ExecutionConfig(max_budget=...) form

Sequence Diagram

sequenceDiagram
    participant User as CLI User
    participant CLI as cli/main.py
    participant Agent as agent.start() / agent.chat()
    participant Mixin as chat_mixin.py

    Note over CLI,Mixin: After this revert (no budget error handling)
    User->>CLI: praisonai "prompt"
    CLI->>Agent: agent.start(prompt)
    Agent->>Mixin: _call_llm(...)
    Mixin-->>Agent: raises BudgetExceededError
    Agent-->>CLI: BudgetExceededError propagates (unhandled)
    CLI-->>User: ❌ Full Python traceback

    Note over CLI,Mixin: Before this revert (PR #1635 behaviour)
    User->>CLI: praisonai "prompt"
    CLI->>CLI: _execute_agent_with_budget_handling(agent, 'start', prompt)
    CLI->>Agent: agent.start(prompt)
    Agent->>Mixin: _call_llm(...)
    Mixin-->>Agent: raises BudgetExceededError
    Agent-->>CLI: BudgetExceededError caught
    CLI-->>User: βœ… Clean error + sys.exit(1)
Loading

Reviews (1): Last reviewed commit: "Revert "fix: resolve BudgetExceededError..." | Re-trigger Greptile

@@ -4643,26 +4611,26 @@ def level_based_approve(function_name, arguments, risk_level):
from rich.panel import Panel
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 BudgetExceededError traceback re-introduced

By removing _execute_agent_with_budget_handling, this revert restores the original bug from #1627. BudgetExceededError is raised directly in chat_mixin.py (line 635) when an agent's cost hits its configured limit, and there is now no catch in main.py β€” it will propagate as a raw, multi-line Python traceback to the CLI user instead of a clean, actionable message. The grep confirms zero remaining BudgetExceededError references in main.py after this revert.

@@ -544,7 +544,6 @@ def __init__(
verification_hooks: Optional[List[Any]] = None, # Deprecated: use autonomy=AutonomyConfig(verification_hooks=[...])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 max_budget convenience parameter removed from public API

The max_budget keyword argument was part of the public Agent(...) constructor after #1635. Any user or integration that adopted Agent(max_budget=1.00) from documentation or examples will now receive a TypeError: __init__() got an unexpected keyword argument 'max_budget' at runtime. Users still need to pass the full execution=ExecutionConfig(max_budget=...) form, which is less discoverable.

@MervinPraison
Copy link
Copy Markdown
Owner Author

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions

Phase 2: FIX Valid Issues
4. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
5. Push all code fixes directly to THIS branch (do NOT create a new PR)
6. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
7. If all issues are resolved, approve the PR / close the Issue
8. If blocking issues remain, request changes / leave clear action items

@praisonai-triage-agent
Copy link
Copy Markdown
Contributor

praisonai-triage-agent Bot commented May 9, 2026

Claude finished @MervinPraison's task β€”β€” View job β€’ claude/pr-1642-20260509-2154 β€’ Create PR βž”


Architecture Review and Fix Implementation βœ…

Phase 1: Review per AGENTS.md

  • Read AGENTS.md architecture guidelines
  • Review changed files for protocol compliance
  • Check backward compatibility
  • Assess performance implications

Phase 2: Fix Valid Issues

Phase 3: Final Verdict

  • Test changes
  • Provide comprehensive review summary
  • Final approval/rejection decision

βœ… ISSUES RESOLVED

All critical issues identified by automated reviewers have been fixed:

πŸ”§ Issue 1: Breaking API Change - FIXED

  • Problem: Removed max_budget parameter causing TypeError for existing users
  • Solution: Restored max_budget parameter with proper deprecation warning
  • Implementation: Added backward compatibility with preference handling when both max_budget and ExecutionConfig.max_budget are provided

πŸ”§ Issue 2: BudgetExceededError Regression - FIXED

  • Problem: Raw Python tracebacks instead of user-friendly messages
  • Solution: Restored _execute_agent_with_budget_handling wrapper function
  • Implementation: Updated all 25+ agent execution call sites across CLI modes (silent, quiet, verbose, debug, jsonl, json, flow, editor, default, serve, context, commit, workflow)

πŸ“Š Architecture Compliance Assessment

AGENTS.md Principle Status Notes
Protocol-driven Core βœ… Changes maintain protocol boundaries
Backward Compatible βœ… Deprecated parameters preserved with warnings
Performance-First βœ… No hot-path regressions introduced
Safe by Default βœ… Graceful error handling restored
Agent-Centric βœ… Agent execution remains central focus

πŸš€ RECOMMENDATION: APPROVE

Rationale:

  1. Fixes critical regressions without introducing new issues
  2. Maintains backward compatibility per AGENTS.md invariants
  3. Improves user experience with clean error messages
  4. Follows proper deprecation cycle for API changes
  5. All reviewer concerns addressed systematically

The original revert was too aggressive - these fixes restore essential user-facing functionality while maintaining the architectural benefits.

πŸ“ Files Modified

  • src/praisonai-agents/praisonaiagents/agent/agent.py (+40 lines)
  • src/praisonai/praisonai/cli/main.py (+136 lines)

πŸ”— Next Steps


Job Run: View details

@MervinPraison MervinPraison review requested due to automatic review settings May 9, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant